﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;

namespace HigLabo.Net.Twitter
{
    public partial class TwitterClient
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="callback"></param>
        public void GetRetweets(Int64 id, Action<StatusCollection> callback)
        {
            this.GetRetweets(new GetRetweetsCommand(id), callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetRetweets(GetRetweetsCommand command, Action<StatusCollection> callback)
        {
            String url = String.Format(TwitterApiUrl.Version1_1.Tweets.GetRetweetsFormatUrl, command.ID);
            this.GetResultText(url, command
                , json => callback(new StatusCollection(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="callback"></param>
        public void GetStatus(Int64 id, Action<Status> callback)
        {
            GetRetweetCommand command = new GetRetweetCommand(id);
            GetStatus(command, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetStatus(GetRetweetCommand command, Action<Status> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Tweets.GetShowFormatUrl, command
                , json => callback(new Status(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="callback"></param>
        public void DestroyStatus(Int64 id, Action<Status> callback)
        {
            DestroyStatus(new RetweetCommand(id), callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void DestroyStatus(RetweetCommand command, Action<Status> callback)
        {
            String url = String.Format(TwitterApiUrl.Version1_1.Tweets.DestroyFormatUrl, command.ID);
            this.GetResultText(HttpMethodName.Post, url, command
                , json => callback(new Status(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="id"></param>
        /// <param name="callback"></param>
        public void RetweetStatus(Int64 id, Action<Status> callback)
        {
            RetweetStatus(new RetweetCommand(id), callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void RetweetStatus(RetweetCommand command, Action<Status> callback)
        {
            String url = String.Format(TwitterApiUrl.Version1_1.Tweets.RetweetFormatUrl, command.ID);
            this.GetResultText(HttpMethodName.Post, url, command
                , json => callback(new Status(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="tweetText"></param>
        /// <param name="callback"></param>
        public void UpdateStatus(String tweetText, Action<Status> callback)
        {
            var cm = new UpdateStatusCommand();
            cm.Status = tweetText;
            this.UpdateStatus(cm, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void UpdateStatus(UpdateStatusCommand command, Action<Status> callback)
        {
            this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.Tweets.UpdateFormatUrl, command
                , json => callback(new Status(json)));
        }
    }
}
